home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 2 code / Using Objects Safely / HandleExample.p next >
Encoding:
Text File  |  1990-03-29  |  584 b   |  32 lines  |  [TEXT/MPS ]

  1. PROGRAM Test;
  2.  
  3. { Can be built using the MacApp command 'MABuild HandleExample' }
  4.  
  5. USES
  6.     UMacApp;
  7.  
  8. TYPE
  9.          TShapeHdl = ^TShapePtr;
  10.         TShapePtr = ^TShape;
  11.         TShape = RECORD
  12.                  fBounds:      Rect;
  13.                  fColor:        RGBColor;
  14.                  END;
  15.  
  16. VAR
  17.     aShape:                  TShapeHdl;
  18.     sameShape, copiedShape: TShapeHdl;
  19.  
  20. BEGIN
  21.     aShape := TShapeHdl(NewHandle(SIZEOF(TShape)));
  22.     FailNIL(aShape);
  23.     
  24.     aShape^^.fBounds := gZeroRect;
  25.     aShape^^.fColor := gRGBBlack;
  26.     
  27.     sameShape := aShape;
  28.     
  29.     copiedShape := aShape;
  30.     FailOSErr(HandToHand(Handle(copiedShape)));
  31.     FailNIL(copiedShape);
  32. END.